package com.java.controller;

import com.java.config.result.Result;
import com.java.model.vo.HospitalQueryVo;
import com.java.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院列表
     * @param pageNum
     * @param pageSize
     * @param hospitalQueryVo
     * @return
     */
    @GetMapping("/pageList/{pageNum}/{pageSize}")
    public Result getPageList(@PathVariable("pageNum") Integer pageNum,
                              @PathVariable("pageSize") Integer pageSize,
                              HospitalQueryVo hospitalQueryVo){
       Page pageModel = hospitalService.selectPageList(pageNum,pageSize,hospitalQueryVo);
       return Result.ok(pageModel);
    }

    /**
     * 设置医院的状态
     * @return
     */
    @GetMapping("/changeStatus/{id}/{status}")
    public Result changeStas(@PathVariable String id,@PathVariable Integer status){
        hospitalService.statusChanged(id,status);
        return Result.ok();
    }

    @GetMapping("/showHospital/{id}")
    public Result showHospital(@PathVariable String id){
        Map<String, Object> result = hospitalService.getHospitalById(id);
        return Result.ok(result);
    }
}
